﻿using Aliyun.OSS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace AliyunOSServiceLib.Services
{
    public interface IAliyunOSService
    {
        /// <summary>
        /// 创建存储空间
        /// </summary>
        Bucket CreateBucket();
        /// <summary>
        /// 列举存储空间
        /// </summary>
        IEnumerable<Bucket> ListBuckets();
        /// <summary>
        /// 判断存储空间是否存在
        /// </summary>
        /// <returns></returns>
        bool DoesBucketExist();
        /// <summary>
        /// 设置存储空间访问权限
        /// </summary>
        /// <returns></returns>
        bool SetBucketAcl(CannedAccessControlList accessEnum);
        /// <summary>
        /// 获取存储空间权限
        /// </summary>
        /// <returns></returns>
        AccessControlList GetBucketAcl();
        /// <summary>
        /// 删除存储空间
        /// </summary>
        /// <returns></returns>
        bool DeleteBucket();
        /// <summary>
        /// 上传文件
        /// </summary>
        bool PutObject(Stream stream,string key);
        /// <summary>
        /// 异步上传
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        bool PutObjectAsync(Stream stream, string objectName);
        /// <summary>
        /// 下载文件
        /// </summary>
        void GetObject(string objectName, string downloadFilename);
        /// <summary>
        /// 判断文件是否存在
        /// </summary>
        /// <param name="objectName"></param>
        /// <returns></returns>
        bool DoesObjectExist(string objectName);
        /// <summary>
        /// 设置文件权限
        /// </summary>
        /// <param name="objectName"></param>
        /// <param name="cannedAccessControlList"></param>
        /// <returns></returns>
        bool SetObjectAcl(string objectName, CannedAccessControlList cannedAccessControlList);
        /// <summary>
        /// 获取文件权限
        /// </summary>
        /// <param name="objectName"></param>
        /// <returns></returns>
        AccessControlList GetObjectAcl(string objectName);
        /// <summary>
        /// 列举文件
        /// </summary>
        IEnumerable<OssObjectSummary> ListObjects(int maxKeys);
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="objectName"></param>
        /// <returns></returns>
        bool DeleteObject(string objectName);
        /// <summary>
        /// 使用授权链接上传文件
        /// </summary>
        /// <param name="objectName"></param>
        /// <param name="expriration"></param>
        /// <returns></returns>
        bool GeneratePresignedUriPutObject(string objectName, byte[] buffer, DateTime expriration);
        /// <summary>
        /// 使用授权链接下载文件
        /// </summary>
        /// <param name="objectName"></param>
        /// <returns></returns>
        OssObject GeneratePresignedUriRequestGetObject(string objectName);
        /// <summary>
        /// 获取授权下载链接
        /// </summary>
        /// <param name="objectName"></param>
        /// <returns></returns>
        string GetGeneratePresignedUri(string objectName,string process="");
    }
}
